gtk_widget_set_hexpand (label, TRUE);
picker = gtk_file_chooser_button_new ("Pick a File",
GTK_FILE_CHOOSER_ACTION_OPEN);
- gtk_file_chooser_set_local_only (GTK_FILE_CHOOSER (picker), FALSE);
gtk_grid_attach (GTK_GRID (table), label, 0, 2, 1, 1);
gtk_grid_attach (GTK_GRID (table), picker, 1, 2, 1, 1);
GtkFileChooserError
gtk_file_chooser_set_action
gtk_file_chooser_get_action
-gtk_file_chooser_set_local_only
-gtk_file_chooser_get_local_only
gtk_file_chooser_set_select_multiple
gtk_file_chooser_get_select_multiple
gtk_file_chooser_set_create_folders
P_("The current filter for selecting which files are displayed"),
GTK_TYPE_FILE_FILTER,
GTK_PARAM_READWRITE));
- g_object_interface_install_property (iface,
- g_param_spec_boolean ("local-only",
- P_("Local Only"),
- P_("Whether the selected file(s) should be limited to local file: URLs"),
- FALSE,
- GTK_PARAM_READWRITE));
g_object_interface_install_property (iface,
g_param_spec_object ("preview-widget",
P_("Preview widget"),
return action;
}
-/**
- * gtk_file_chooser_set_local_only:
- * @chooser: a #GtkFileChooser
- * @local_only: %TRUE if only local files can be selected
- *
- * Sets whether only local files can be selected in the
- * file selector. If @local_only is %TRUE (the default is %FALSE),
- * then the selected file or files are guaranteed to be
- * accessible through the operating system’s native file
- * system and therefore the application only
- * needs to worry about the filename functions in
- * #GtkFileChooser, like gtk_file_chooser_get_file().
- *
- * On some systems non-native files may still be
- * available using the native filesystem via a userspace
- * filesystem (FUSE).
- **/
-void
-gtk_file_chooser_set_local_only (GtkFileChooser *chooser,
- gboolean local_only)
-{
- g_return_if_fail (GTK_IS_FILE_CHOOSER (chooser));
-
- g_object_set (chooser, "local-only", local_only, NULL);
-}
-
-/**
- * gtk_file_chooser_get_local_only:
- * @chooser: a #GtkFileChooser
- *
- * Gets whether only local files can be selected in the
- * file selector. See gtk_file_chooser_set_local_only()
- *
- * Returns: %TRUE if only local files can be selected.
- **/
-gboolean
-gtk_file_chooser_get_local_only (GtkFileChooser *chooser)
-{
- gboolean local_only;
-
- g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), FALSE);
-
- g_object_get (chooser, "local-only", &local_only, NULL);
-
- return local_only;
-}
-
/**
* gtk_file_chooser_set_select_multiple:
* @chooser: a #GtkFileChooser
GDK_AVAILABLE_IN_ALL
GtkFileChooserAction gtk_file_chooser_get_action (GtkFileChooser *chooser);
GDK_AVAILABLE_IN_ALL
-void gtk_file_chooser_set_local_only (GtkFileChooser *chooser,
- gboolean local_only);
-GDK_AVAILABLE_IN_ALL
-gboolean gtk_file_chooser_get_local_only (GtkFileChooser *chooser);
-GDK_AVAILABLE_IN_ALL
void gtk_file_chooser_set_select_multiple (GtkFileChooser *chooser,
gboolean select_multiple);
GDK_AVAILABLE_IN_ALL
static void chooser_update_preview_cb (GtkFileChooser *dialog,
gpointer user_data);
-static void chooser_notify_cb (GObject *dialog,
- GParamSpec *pspec,
- gpointer user_data);
static void dialog_response_cb (GtkDialog *dialog,
gint response,
gpointer user_data);
(gpointer) (&priv->dialog));
}
- g_signal_connect (priv->chooser, "notify",
- G_CALLBACK (chooser_notify_cb), object);
-
/* This is used, instead of the standard delegate, to ensure that signals are only
* delegated when the OK button is pressed. */
g_object_set_qdata (object, GTK_FILE_CHOOSER_DELEGATE_QUARK, priv->chooser);
g_object_set_property (G_OBJECT (priv->chooser), pspec->name, value);
break;
- case GTK_FILE_CHOOSER_PROP_LOCAL_ONLY:
- g_object_set_property (G_OBJECT (priv->chooser), pspec->name, value);
- fs_volumes_changed_cb (priv->fs, button);
- bookmarks_changed_cb (button);
- break;
-
case GTK_FILE_CHOOSER_PROP_SELECT_MULTIPLE:
g_warning ("%s: Choosers of type '%s' do not support selecting multiple files.",
G_STRFUNC, G_OBJECT_TYPE_NAME (object));
case PROP_TITLE:
case GTK_FILE_CHOOSER_PROP_ACTION:
case GTK_FILE_CHOOSER_PROP_FILTER:
- case GTK_FILE_CHOOSER_PROP_LOCAL_ONLY:
case GTK_FILE_CHOOSER_PROP_PREVIEW_WIDGET:
case GTK_FILE_CHOOSER_PROP_PREVIEW_WIDGET_ACTIVE:
case GTK_FILE_CHOOSER_PROP_USE_PREVIEW_LABEL:
GtkFileChooserButtonPrivate *priv = gtk_file_chooser_button_get_instance_private (button);
GtkListStore *store;
gint pos;
- gboolean local_only;
GSList *l;
if (!volumes)
store = GTK_LIST_STORE (priv->model);
pos = model_get_type_position (button, ROW_TYPE_VOLUME);
- local_only = gtk_file_chooser_get_local_only (GTK_FILE_CHOOSER (priv->chooser));
for (l = volumes; l; l = l->next)
{
gchar *display_name;
volume = l->data;
-
- if (local_only)
- {
- if (_gtk_file_system_volume_is_mounted (volume))
- {
- GFile *base_file;
-
- base_file = _gtk_file_system_volume_get_root (volume);
- if (base_file != NULL)
- {
- if (!_gtk_file_has_native_path (base_file))
- {
- g_object_unref (base_file);
- continue;
- }
- else
- g_object_unref (base_file);
- }
- }
- }
-
icon = _gtk_file_system_volume_get_icon (volume);
display_name = _gtk_file_system_volume_get_display_name (volume);
GtkListStore *store;
GtkTreeIter iter;
gint pos;
- gboolean local_only;
GSList *l;
if (!bookmarks)
store = GTK_LIST_STORE (priv->model);
pos = model_get_type_position (button, ROW_TYPE_BOOKMARK);
- local_only = gtk_file_chooser_get_local_only (GTK_FILE_CHOOSER (priv->chooser));
for (l = bookmarks; l; l = l->next)
{
gchar *label;
GIcon *icon;
- if (local_only)
- continue;
-
/* Don't call get_info for remote paths to avoid latency and
* auth dialogs.
* If we switch to a better bookmarks file format (XBEL), we
static gboolean
test_if_file_is_visible (GtkFileSystem *fs,
GFile *file,
- gboolean local_only,
gboolean is_folder)
{
if (!file)
return FALSE;
- if (local_only && !_gtk_file_has_native_path (file))
- return FALSE;
-
if (!is_folder)
return FALSE;
GtkFileChooserButtonPrivate *priv = gtk_file_chooser_button_get_instance_private (button);
gchar type;
gpointer data;
- gboolean local_only, retval, is_folder;
+ gboolean retval, is_folder;
type = ROW_TYPE_INVALID;
data = NULL;
- local_only = gtk_file_chooser_get_local_only (GTK_FILE_CHOOSER (priv->chooser));
gtk_tree_model_get (model, iter,
TYPE_COLUMN, &type,
case ROW_TYPE_SPECIAL:
case ROW_TYPE_SHORTCUT:
case ROW_TYPE_BOOKMARK:
- retval = test_if_file_is_visible (priv->fs, data, local_only, is_folder);
+ retval = test_if_file_is_visible (priv->fs, data, is_folder);
break;
case ROW_TYPE_VOLUME:
- {
- retval = TRUE;
- if (local_only)
- {
- if (_gtk_file_system_volume_is_mounted (data))
- {
- GFile *base_file;
-
- base_file = _gtk_file_system_volume_get_root (data);
-
- if (base_file)
- {
- if (!_gtk_file_has_native_path (base_file))
- retval = FALSE;
- g_object_unref (base_file);
- }
- else
- retval = FALSE;
- }
- }
- }
+ retval = TRUE;
break;
default:
retval = TRUE;
g_signal_emit_by_name (user_data, "update-preview");
}
-static void
-chooser_notify_cb (GObject *dialog,
- GParamSpec *pspec,
- gpointer user_data)
-{
- gpointer iface;
-
- iface = g_type_interface_peek (g_type_class_peek (G_OBJECT_TYPE (dialog)),
- GTK_TYPE_FILE_CHOOSER);
- if (g_object_interface_find_property (iface, pspec->name))
- g_object_notify (user_data, pspec->name);
-
- if (g_ascii_strcasecmp (pspec->name, "local-only") == 0)
- {
- GtkFileChooserButton *button = GTK_FILE_CHOOSER_BUTTON (user_data);
- GtkFileChooserButtonPrivate *priv = gtk_file_chooser_button_get_instance_private (button);
-
- if (priv->has_current_folder)
- {
- GtkTreeIter iter;
- gint pos;
- gpointer data;
-
- pos = model_get_type_position (user_data,
- ROW_TYPE_CURRENT_FOLDER);
- gtk_tree_model_iter_nth_child (priv->model, &iter, NULL, pos);
-
- data = NULL;
- gtk_tree_model_get (priv->model, &iter, DATA_COLUMN, &data, -1);
-
- /* If the path isn't local but we're in local-only mode now, remove
- * the custom-folder row */
- if (data && _gtk_file_has_native_path (G_FILE (data)) &&
- gtk_file_chooser_get_local_only (GTK_FILE_CHOOSER (priv->chooser)))
- {
- pos--;
- model_remove_rows (user_data, pos, 2);
- }
- }
-
- gtk_tree_model_filter_refilter (GTK_TREE_MODEL_FILTER (priv->filter_model));
- update_combo_box (user_data);
- }
-}
-
static void
common_response_cb (GtkFileChooserButton *button,
gint response)
g_object_class_override_property (klass,
GTK_FILE_CHOOSER_PROP_FILTER,
"filter");
- g_object_class_override_property (klass,
- GTK_FILE_CHOOSER_PROP_LOCAL_ONLY,
- "local-only");
g_object_class_override_property (klass,
GTK_FILE_CHOOSER_PROP_PREVIEW_WIDGET,
"preview-widget");
GTK_FILE_CHOOSER_PROP_FIRST = 0x1000,
GTK_FILE_CHOOSER_PROP_ACTION = GTK_FILE_CHOOSER_PROP_FIRST,
GTK_FILE_CHOOSER_PROP_FILTER,
- GTK_FILE_CHOOSER_PROP_LOCAL_ONLY,
GTK_FILE_CHOOSER_PROP_PREVIEW_WIDGET,
GTK_FILE_CHOOSER_PROP_PREVIEW_WIDGET_ACTIVE,
GTK_FILE_CHOOSER_PROP_USE_PREVIEW_LABEL,
/* Flags */
- guint local_only : 1;
guint preview_widget_active : 1;
guint use_preview_label : 1;
guint select_multiple : 1;
g_signal_connect_swapped (priv->location_entry, "hide-entry",
G_CALLBACK (location_entry_close_clicked), impl);
- _gtk_file_chooser_entry_set_local_only (GTK_FILE_CHOOSER_ENTRY (priv->location_entry), priv->local_only);
+ _gtk_file_chooser_entry_set_local_only (GTK_FILE_CHOOSER_ENTRY (priv->location_entry), FALSE);
_gtk_file_chooser_entry_set_action (GTK_FILE_CHOOSER_ENTRY (priv->location_entry), priv->action);
_gtk_file_chooser_entry_set_file_filter (GTK_FILE_CHOOSER_ENTRY (priv->location_entry),
priv->current_filter);
g_object_unref (home_file);
}
-static void
-set_local_only (GtkFileChooserWidget *impl,
- gboolean local_only)
-{
- GtkFileChooserWidgetPrivate *priv = gtk_file_chooser_widget_get_instance_private (impl);
-
- if (local_only != priv->local_only)
- {
- priv->local_only = local_only;
-
- if (priv->location_entry)
- _gtk_file_chooser_entry_set_local_only (GTK_FILE_CHOOSER_ENTRY (priv->location_entry), local_only);
-
- gtk_places_sidebar_set_local_only (GTK_PLACES_SIDEBAR (priv->places_sidebar), local_only);
-
- if (local_only && priv->current_folder &&
- !_gtk_file_has_native_path (priv->current_folder))
- {
- /* If we are pointing to a non-local folder, make an effort to change
- * back to a local folder, but it's really up to the app to not cause
- * such a situation, so we ignore errors.
- */
- switch_to_home_dir (impl);
- }
- }
-}
-
/* Sets the file chooser to multiple selection mode */
static void
set_select_multiple (GtkFileChooserWidget *impl,
(priv->operation_mode == OPERATION_MODE_BROWSE &&
priv->location_mode == LOCATION_MODE_FILENAME_ENTRY))
{
- if (priv->local_only)
- subtitle = g_strdup (_("Enter location"));
- else
- subtitle = g_strdup (_("Enter location or URL"));
+ subtitle = g_strdup (_("Enter location or URL"));
}
return subtitle;
set_current_filter (impl, g_value_get_object (value));
break;
- case GTK_FILE_CHOOSER_PROP_LOCAL_ONLY:
- set_local_only (impl, g_value_get_boolean (value));
- break;
-
case GTK_FILE_CHOOSER_PROP_PREVIEW_WIDGET:
set_preview_widget (impl, g_value_get_object (value));
break;
g_value_set_object (value, priv->current_filter);
break;
- case GTK_FILE_CHOOSER_PROP_LOCAL_ONLY:
- g_value_set_boolean (value, priv->local_only);
- break;
-
case GTK_FILE_CHOOSER_PROP_PREVIEW_WIDGET:
g_value_set_object (value, priv->preview_widget);
break;
operation_mode_set (impl, OPERATION_MODE_BROWSE);
- if (priv->local_only && !_gtk_file_has_native_path (file))
- {
- g_set_error_literal (error,
- GTK_FILE_CHOOSER_ERROR,
- GTK_FILE_CHOOSER_ERROR_BAD_FILENAME,
- _("Cannot change to folder because it is not local"));
-
- g_object_unref (file);
- profile_end ("end - not local", NULL);
- return FALSE;
- }
-
if (priv->update_current_folder_cancellable)
g_cancellable_cancel (priv->update_current_folder_cancellable);
access ("MARK: *** CREATE FILE CHOOSER", F_OK);
#endif
- priv->local_only = FALSE;
priv->preview_widget_active = TRUE;
priv->use_preview_label = TRUE;
priv->select_multiple = FALSE;
<property name="vexpand">1</property>
<child>
<object class="GtkPlacesSidebar" id="places_sidebar">
- <property name="local-only">1</property>
+ <property name="local-only">0</property>
<property name="show-other-locations">1</property>
<style>
<class name="sidebar"/>
<property name="name">other_locations</property>
<property name="child">
<object class="GtkPlacesView" id="places_view">
- <property name="local-only" bind-source="GtkFileChooserWidget" bind-property="local-only" bind-flags="default|sync-create"/>
+ <property name="local-only">0</property>
<signal name="open-location" handler="places_sidebar_open_location_cb" swapped="no"/>
<signal name="show-error-message" handler="places_sidebar_show_error_message_cb" swapped="no"/>
</object>
GtkFileFilter *filter;
gboolean force_rtl = FALSE;
gboolean multiple = FALSE;
- gboolean local_only = FALSE;
char *action_arg = NULL;
char *initial_filename = NULL;
char *initial_folder = NULL;
GOptionEntry options[] = {
{ "action", 'a', 0, G_OPTION_ARG_STRING, &action_arg, "Filechooser action", "ACTION" },
{ "multiple", 'm', 0, G_OPTION_ARG_NONE, &multiple, "Select multiple", NULL },
- { "local-only", 'l', 0, G_OPTION_ARG_NONE, &local_only, "Local only", NULL },
{ "right-to-left", 'r', 0, G_OPTION_ARG_NONE, &force_rtl, "Force right-to-left layout.", NULL },
{ "initial-filename", 'f', 0, G_OPTION_ARG_FILENAME, &initial_filename, "Initial filename to select", "FILENAME" },
{ "initial-folder", 'F', 0, G_OPTION_ARG_FILENAME, &initial_folder, "Initial folder to show", "FILENAME" },
dialog = g_object_new (GTK_TYPE_FILE_CHOOSER_DIALOG,
"action", action,
"select-multiple", multiple,
- "local-only", local_only,
NULL);
switch (action)
static const IgnoreProperty bug_properties[] = {
{ "GtkComboBox", "active", (void*) MATCH_ANY_VALUE }, /* FIXME: triggers NULL model bug */
{ "GtkCTree", "spacing", (void*) MATCH_ANY_VALUE }, /* FIXME: triggers signedness bug */
- { "GtkFileChooserButton", "local-only", (void*) MATCH_ANY_VALUE }, /* FIXME: triggers NULL path assertion */
- { "GtkFileChooserDialog", "local-only", (void*) MATCH_ANY_VALUE }, /* FIXME: triggers NULL path assertion */
- { "GtkFileChooserWidget", "local-only", (void*) MATCH_ANY_VALUE }, /* FIXME: triggers NULL path assertion */
{ "GtkText", "text-position", (void*) MATCH_ANY_VALUE }, /* FIXME: segfaults, fix property minimum/maximum */
{ NULL, NULL, NULL }
};